package cn.harry.modular.society.service.impl;

import cn.harry.modular.society.domain.Huodongshenqing;
import cn.harry.modular.society.domain.Yonghuhuodong;
import cn.harry.modular.society.mapper.HuodongshenqingMapper;
import cn.harry.modular.society.service.HuodongshenqingService;
import cn.harry.modular.society.service.YonghuhuodongService;
import cn.harry.modular.society.vo.EchartsOptionVO;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @description 针对表【t_huodongshenqing(活动申请)】的数据库操作Service实现
 * @createDate 2025-04-12 20:50:54
 */
@Service
@AllArgsConstructor
public class HuodongshenqingServiceImpl extends ServiceImpl<HuodongshenqingMapper, Huodongshenqing> implements HuodongshenqingService {
    private final YonghuhuodongService yonghuhuodongService;

    @Override
    public EchartsOptionVO getHuodongUser() {
        EchartsOptionVO vo = new EchartsOptionVO();
        List<Huodongshenqing> list = list();
        if (CollUtil.isNotEmpty(list)) {
            // 根据成果类型分组
            JSONArray x = new JSONArray();
            JSONArray y = new JSONArray();
            for (Huodongshenqing act : list) {
                x.put(act.getHuodongmingcheng());
                Long actId = act.getId();
                long count = yonghuhuodongService.count(Wrappers.<Yonghuhuodong>lambdaQuery().eq(Yonghuhuodong::getHuodongId, actId));
                y.put(count);
                vo.setXData(x);
                vo.setYData(y);
            }
        }
        return vo;
    }
}




